﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
using System.Threading.Tasks;

namespace Repository.communal
{
    public interface IBaseRepository<T> where T : class, new()
    {
        /// <summary>
        /// 添加数据
        /// </summary>
        /// <param name="t">添加实体</param>
        /// <returns>受影响行数</returns>
        Task<int> AddAsync(T t);
        /// <summary>
        /// 添加数据
        /// </summary>
        /// <param name="t">添加实体</param>
        /// <returns>受影响行数</returns>
        Task<int> Update(T t);
        /// <summary>
        ///查询单条数据
        /// </summary>
        /// <param name="id">根据编号查询</param>
        /// <returns>符合条件的数据</returns>
        Task<T> GetModelAsync(int id);
        Task<List<T>> GetAllAsync();
        Task<List<T>> GetAsync(Expression<Func<T, bool>> expre);
        Task<int> AddRange(T t);

        /// <summary>
        /// 批量添加
        /// </summary>
        /// <param name="entity">添加数组</param>
        /// <returns>返回受影响行数</returns>
        Task<int> BatchAdd(List<T> entity);


        /// <summary>
        /// 批量修改
        /// </summary>
        /// <param name="entity">修改数组</param>
        /// <returns>返回受影响行数</returns>
        Task<int> BatchUpdate(List<T> entity);
    }
}
